#include "mainwindow.h"
#include "ui_mainwindow.h"

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    i=0;
    animation_type=1;
}

MainWindow::~MainWindow()
{
    delete ui;
}


void MainWindow::on_pushButton_clicked()
{   animation_type=1;
    this->i+=10;
    repaint();
}


void MainWindow::on_pushButton_2_clicked()
{
    animation_type=2;
     repaint();
}

void MainWindow::paintEvent(QPaintEvent *ev)
{
    QPainter p(this);//窗口作为画板
    if(animation_type==1)
    {QPixmap s("://image/OIP-C.jfif");
    QTransform tf;
    tf.translate(width()/2,0);

    p.setTransform(tf);
    p.drawPixmap(0,0,s);}
    else if(animation_type==2)
    {
        QPixmap s("://image/OIP-C.jfif");
        QTransform tf;
        tf.translate(width()/2,0);
        tf.rotate(60,Qt::YAxis);

        p.setTransform(tf);
        p.drawPixmap(i,i,s);
    }

}

